package com.example.oasystem.service.impl;


import com.example.oasystem.dao.dept.AoaDeptDao;
import com.example.oasystem.entity.dept.AoaDept;
import com.example.oasystem.entity.user.AoaUser;
import com.example.oasystem.service.AoaDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AoaDeptServiceImpl implements AoaDeptService {
    @Autowired
    private AoaDeptDao aoaDeptDao;

    @Override
    public List<AoaDept> selectByRole(AoaUser user) {
        int value = user.getRoleId().intValue();
        List<AoaDept> depts = new ArrayList<>();
        switch (value){
            case 1:
                //超级管理员
            case 2:
                //CEO
            case 3:
                //总经理
                depts = aoaDeptDao.selectAll();
                break;
            case 4:
                //部门经理
                depts.add(aoaDeptDao.selectById(user.getDeptId()));
                break;
            default:
                break;
        }
        return depts;
    }
    @Override
    public List<AoaDept> selectAll() {
        return aoaDeptDao.selectAll();
    }

    @Override
    public AoaUser selectDeptManagerById(Long deptId) {
        return aoaDeptDao.selectDeptManagerById(deptId);
    }
}
